//
//  ALPS_TComprehensiveTCell.m
//  Alps
//
//  Created by dllo on 16/6/12.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ALPS_TComprehensiveTCell.h"

@implementation ALPS_TComprehensiveTCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.smallView = [[UIImageView alloc] init];
        self.smallView.layer.borderWidth = 1;
        self.smallView.layer.borderColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:1.00].CGColor;
        [self.contentView addSubview:_smallView];
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:16];
        [self.contentView addSubview:_titleLabel];
        
        self.columnLabel = [[UILabel alloc] init];
        self.columnLabel.font = [UIFont systemFontOfSize:14];
        self.columnLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_columnLabel];
        
        self.numberLabel = [[UILabel alloc] init];
        self.numberLabel.font = [UIFont systemFontOfSize:14];
        self.numberLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_numberLabel];
        
        self.lineLabel = [[UILabel alloc] init];
        self.lineLabel.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:_lineLabel];
        
        self.playView = [[UIImageView alloc] init];
        self.playView.image = [UIImage imageNamed:@"album_play"];
        [self.contentView addSubview:_playView];

    }

    return self;


}

-(void)layoutSubviews
{
    [super layoutSubviews];
    [self.smallView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.left.equalTo(self.contentView).offset(10);
        make.height.equalTo(ScreeHeight / 667 * 80);
        make.width.equalTo(ScreeWidth / 375 * 80);
        
    }];
    
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.left.equalTo(self.smallView.right).offset(10);
        make.height.equalTo(20);
        make.width.equalTo(200);
    }];
    
    [self.columnLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.bottom).offset(10);
        make.left.equalTo(self.smallView.right).offset(10);
        make.height.equalTo(20);
        make.width.equalTo(150);
    }];
    
    [self.numberLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.columnLabel.bottom).offset(10);
        make.left.equalTo(self.smallView.right).offset(10);
        make.height.equalTo(16);
        make.width.equalTo(200);
    }];
    
    [self.lineLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.numberLabel.bottom).offset(10);
        make.left.equalTo(self.contentView).offset(100);
        make.width.equalTo(self.contentView.width);
        make.height.equalTo(1);
    }];
    
    [self.playView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(30);
        make.right.equalTo(self.contentView).offset(-10);
        make.height.equalTo(12);
        make.width.equalTo(12);
    }];

}

-(void)setModel:(ALPS_TRadioModel *)model
{
    if (_model != model) {
        _model = model;
        [self.smallView sd_setImageWithURL:[NSURL URLWithString:model.coverLarge] placeholderImage:[UIImage imageNamed:@"PlaceHolder"]];
        self.titleLabel.text = model.name;
        if (model.programName == NULL) {
            self.columnLabel.text = [NSString stringWithFormat:@"直播中: 暂无节目单"];
        }else
        {
            self.columnLabel.text = [NSString stringWithFormat:@"直播中: %@", model.programName];
        }
        if (model.playCount < 10000) {
            self.numberLabel.text = [NSString stringWithFormat:@"收听人数: %ld人", model.playCount];
        }else
        {
            self.numberLabel.text = [NSString stringWithFormat:@"收听人数: %ld万人", model.playCount / 10000];
        }

    }
    
}


-(void)setDataModel:(ALPS_TCWRadioModel *)dataModel
{
    if (_dataModel != dataModel) {
        _dataModel = dataModel;
        [self.smallView sd_setImageWithURL:[NSURL URLWithString:dataModel.radioCoverLarge]];
        self.titleLabel.text = dataModel.rname;
        if (dataModel.programName == NULL) {
            self.columnLabel.text = [NSString stringWithFormat:@"直播中: 暂无节目单"];
        }else
        {
            self.columnLabel.text = [NSString stringWithFormat:@"直播中: %@", dataModel.programName];
        }
        if (dataModel.radioPlayCount < 10000) {
            self.numberLabel.text = [NSString stringWithFormat:@"收听人数: %ld人", dataModel.radioPlayCount];
        }else
        {
            self.numberLabel.text = [NSString stringWithFormat:@"收听人数: %ld万人", dataModel.radioPlayCount / 10000];
        }
        
    }        
}

-(void)setModelP:(ALPS_TPRadioModel *)modelP
{
    if (_modelP != modelP) {
        _modelP = modelP;
        
        [self.smallView sd_setImageWithURL:[NSURL URLWithString:modelP.radioCoverLarge]];
        self.titleLabel.text = modelP.rname;
        if (modelP.programName == NULL) {
            self.columnLabel.text = [NSString stringWithFormat:@"直播中: 暂无节目单"];
        }else
        {
            self.columnLabel.text = [NSString stringWithFormat:@"直播中: %@", modelP.programName];
        }
        if (modelP.radioPlayCount < 10000) {
            self.numberLabel.text = [NSString stringWithFormat:@"收听人数: %ld人", modelP.radioPlayCount];
        }else
        {
            self.numberLabel.text = [NSString stringWithFormat:@"收听人数: %ld万人", modelP.radioPlayCount / 10000];
        }

        
    }


}



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
